import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
// 创建store方法
import configStore from './redux';
// 提供store数据给react应用
import { Provider } from 'react-redux'
import { reducer } from './redux/reducer';
// import { createStore } from 'redux';
// import { reducer } from './redux/reducer';
// import { addTodoAction, delTodoAction, toggleTodoAction } from './redux/actions';


ReactDOM.render(
  <Provider store={configStore(reducer)}>
    <App />
  </Provider>,
  document.getElementById('root')
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();


// // 测试store
// // 创建store
// const store = createStore(reducer);
// // 订阅store数据的变化
// store.subscribe(()=>{
//   console.log('state变化了：', store.getState())
// })

// // 修改store的数据
// store.dispatch(addTodoAction('今天练习todo！'))
// store.dispatch(addTodoAction('今天还要吃饭！'))
// store.dispatch(delTodoAction(1))
// store.dispatch(toggleTodoAction(0))
// store.dispatch(toggleTodoAction(0))
